<?php


namespace app\api\validate;


use think\Validate;

class File extends Validate
{
    /**
     * @var string[] 验证规则
     */
    protected $rule = [
        'file' => 'require|file',
        'tid' => 'number',
        'ids' => 'require|array',
        'id' => 'require|number',
        'filename' => 'require'
    ];

    /**
     * @var string[] 验证不同过的错误提示
     */
    protected $message = [
        'file.require' => '请选择上传文件!',
        'file.file' => '上传文件不存在!',
        'tid.number' => '附件类别参数不正确!',
        'ids.require' => '附件id不能为空!',
        'ids.array' => '附件参数不正确!',
        'id.require' => '附件id不能为空!',
        'id.number' => '附件id参数类型不正确!',
        'filename.require' => '附件名称不能为空!'
    ];

    /**
     * @var \string[][] 验证场景
     */
    protected $scene = [
        'uploads' => ['file', 'tid'],
        'delete' => ['ids'],
        'classify' => ['ids', 'tid'],
        'rename' => ['id', 'filename'],
        'detail' => ['id']
    ];
}